<?php

namespace SL\FrontBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use SL\FrontBundle\Entity\PresseRepository;

class PresseController extends Controller
{
	public function getPresseIndexAction()
	{
		$repository = $this->getDoctrine()->getManager()->getRepository('SLFrontBundle:Presse');
	
		$list_presse = $repository->getAllPresseWithThumbnail();
		
		return $this->render('SLFrontBundle:Presse:index.html.twig', array('list_presse' => $list_presse, 'template' => "press", 'menu' => "press", 'js' => "default"));
	}

	public function getPresseAction($url)
    {		
		$repository = $this->getDoctrine()->getManager()->getRepository('SLFrontBundle:Presse');
	
		$presse = $repository->getPresseWithImages($url);
		if ($presse === null)
		{
			throw $this->createNotFoundException('Article : '.$url.' inexistant.');
		}
		
		$images = $presse->getImages();
		
        return $this->render('SLFrontBundle:Presse:presse.html.twig', array('presse' => $presse, 'images' => $images, 'template' => "publication", 'menu' => "press", 'js' => "default"));
    }
}
